package cn.monkey.transport.netty.server.codec.protocol.tcp.http;

import cn.monkey.transport.netty.server.codec.protocol.AbstractServerProtocolRouterFunction;
import io.netty.buffer.ByteBuf;
import io.netty.channel.Channel;

import java.util.function.BiPredicate;
import java.util.function.Consumer;

public class HttpServerProtocolRouterFunction extends AbstractServerProtocolRouterFunction {

    public HttpServerProtocolRouterFunction(BiPredicate<Channel, ByteBuf> predicate,
                                            HttpServerProtocolConfig httpServerProtocolConfig,
                                            Consumer<Channel> consumer) {
        super(HttpServerProtocolPredicate.INSTANCE.and(predicate), ((HttpServerProtocolConsumer) () -> httpServerProtocolConfig).andThen(consumer));
    }

    public HttpServerProtocolRouterFunction(BiPredicate<Channel, ByteBuf> predicate,
                                            Consumer<Channel> consumer) {
        super(HttpServerProtocolPredicate.INSTANCE.and(predicate), HttpServerProtocolConsumer.INSTANCE.andThen(consumer));
    }

    public HttpServerProtocolRouterFunction(Consumer<Channel> consumer) {
        super(HttpServerProtocolPredicate.INSTANCE, HttpServerProtocolConsumer.INSTANCE.andThen(consumer));
    }
}
